import * as bodyParser from "body-parser";
import * as morgan from 'morgan'
import * as cors from 'cors';
import { errMsg, sucMsg, sucLoginData, sucDataList, sucData,} from './binMiddlewares'

// 挂载中间件
export default function useMiddleware(app: any) {

  app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }))
  app.use(bodyParser.json({ limit: '50mb' }))
  app.use(cors()) // 允许跨域请求中间件
  app.use(morgan('dev')) // 日志中间件

  // 挂载自定义中间件
  app.use(errMsg)
    .use(sucMsg)
    .use(sucLoginData)
    .use(sucDataList)
    .use(sucData)
}